package com.zack.paymoudle.alipay;

import android.app.Activity;

import com.alipay.sdk.app.EnvUtils;

/**
 * Created by Zackv on 2018/4/25.
 */

public class AlipayConfig {

    private String orderInfo;
    private Activity context;

    private AlipayConfig() {

    }

    public String getOrderInfo() {
        return orderInfo;
    }

    public Activity getContext() {
        return context;
    }

    public static class Builder {
        private String orderInfo;
        private Activity context;

        public Builder() {
            super();
        }

        public AlipayConfig.Builder with(Activity context) {
            this.context = context;
            return this;
        }

        /**
         * 设置支付宝支付OrderInfo
         *
         * @param orderInfo
         * @return
         */
        public AlipayConfig.Builder setOrderInfo(String orderInfo) {
            this.orderInfo = orderInfo;
            return this;
        }
        public AlipayConfig.Builder useSandBox(boolean useSandBox) {
            if(useSandBox){
                EnvUtils.setEnv(EnvUtils.EnvEnum.SANDBOX);
            }
            return this;
        }

        public AlipayConfig build() {
            AlipayConfig aliPayPayConfig = new AlipayConfig();
            aliPayPayConfig.context = this.context;
            aliPayPayConfig.orderInfo = this.orderInfo;
            return aliPayPayConfig;
        }
    }
}
